package model;

public class Adresse extends ModelID{
	
	private String ort;
	private String plz;
	private String strasse;
	private String land;
	

	
	
	
	public Adresse(String ort, String plz, String strasse, String land) {
		setOrt(ort);
		setPlz(plz);
		setStrasse(strasse);
		setLand(land);
	}
	
	
	public String getOrt() {
		return ort;
	}
	public String getPlz() {
		return plz;
	}
	public String getStrasse() {
		return strasse;
	}
	
	public void setOrt(String ort) {
		if(ort == null || ort.trim().length() == 0) throw new IllegalArgumentException("Ort darf nicht null sein!");
		this.ort = ort;
	}
	public void setPlz(String plz) {
		if(plz == null || plz.trim().length() == 0) throw new IllegalArgumentException("PLZ darf nicht null sein!");
		try{
		Integer.valueOf(plz);
		}
		catch (Exception e)
		{
		  throw new IllegalArgumentException("PLZ darf nur aus Zahlen bestehen!");
		  
		}
		this.plz = plz;
	}
	public void setStrasse(String strasse) {
		if(strasse == null || strasse.trim().length() == 0) throw new IllegalArgumentException("Strasse darf nicht null sein!");
		this.strasse = strasse;
	}
	
	public String getLand() {
		return land;
	}


	public void setLand(String land) {
		if(land == null || land.trim().length() == 0) throw new IllegalArgumentException("Land darf nicht null sein!");
		this.land = land;
	}


	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((land == null) ? 0 : land.hashCode());
		result = prime * result + ((ort == null) ? 0 : ort.hashCode());
		result = prime * result + ((plz == null) ? 0 : plz.hashCode());
		result = prime * result + ((strasse == null) ? 0 : strasse.hashCode());
		return result;
	}


	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Adresse other = (Adresse) obj;
		if (land == null) {
			if (other.land != null)
				return false;
		} else if (!land.equals(other.land))
			return false;
		if (ort == null) {
			if (other.ort != null)
				return false;
		} else if (!ort.equals(other.ort))
			return false;
		if (plz == null) {
			if (other.plz != null)
				return false;
		} else if (!plz.equals(other.plz))
			return false;
		if (strasse == null) {
			if (other.strasse != null)
				return false;
		} else if (!strasse.equals(other.strasse))
			return false;
		return true;
	}

	

}
